package com.gserver.game.plugin.impl;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

import com.gserver.game.character.Player;
import com.gserver.game.plugin.IPointPlugin;

/**
 * 玩家相关的插件,完成以下功能:
 * <ul>
 * 当登录第一次登录时,给予玩家指定的物品,装备,扩展点{@link PlayerPluginPoint#ENTER}
 * </ul>
 * 
 * 
 * 
 */
@SuppressWarnings("unchecked")
public class PlayerPlugin implements IPointPlugin<PlayerPluginPoint, Player> {


	private volatile boolean start = false;

	private Map<Integer, Map<?, ?>> jobConfig = new HashMap<Integer, Map<?, ?>>();

	private Object config;

	private final EnumSet<PlayerPluginPoint> pointSet = EnumSet
			.noneOf(PlayerPluginPoint.class);

	/**
	 * 
	 * @param config
	 */
	public PlayerPlugin(Object config) {
		if (config == null) {
			return;
		}
		this.config = config;
		pointSet.add(PlayerPluginPoint.ENTER);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.mop..gameserver.extra.impl.IPointPlugin#fire(com.mop..gameserver
	 * .extra.impl.PluginPoint)
	 */
	public boolean fire(PlayerPluginPoint point, Player player) {
		if (!start) {
			return false;
		}
		PlayerPluginPoint _point = (PlayerPluginPoint) point;
		if (_point == PlayerPluginPoint.ENTER) {
			onLogin(player);
			return true;
		} else if (_point == PlayerPluginPoint.CREATE_CHARACTER) {

		}
		return false;
	}

	public boolean start() {
		start = true;
		return start;
	}

	public boolean stop() {
		start = false;
		return true;
	}

	public EnumSet<PlayerPluginPoint> getPluginPoint() {
		return pointSet;
	}

	/**
	 * 处理玩家初始登录时的功能,给予玩家物品奖励
	 * 
	 * @param player
	 */
	private void onLogin(Player player) {

	}

	public void init() {

	}

	public void check() {

	}
}
